Passed
Pull Request — master (#2)
by Muhammad Dyas
02:13
created

BaseCard.make   A

Complexity

Conditions 1

Size

Total Lines 5
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 1
1
import {chat_v1 as chatV1} from 'googleapis/build/src/apis/chat/v1';
2
3
interface Card {
4
  buildHeader?(): void;
5
6
  buildSections(): void;
7
8
  buildButtons?(): void;
9
10
  buildFooter?(): void;
11
12
  make(): chatV1.Schema$CardWithId;
13
}
14
15
export abstract class BaseCard implements Card {
16
  private id: string = 'cardId';
17
  private _content: chatV1.Schema$GoogleAppsCardV1Section[] = [];
18
19
  protected card: chatV1.Schema$GoogleAppsCardV1Card = {
20
    sections: this._content,
21
  };
22
23
  abstract buildSections(): void;
24
25
  make(): chatV1.Schema$CardWithId {
26
    return {
27
      'cardId': this.id,
28
      'card': this.card,
29
    };
30
  }
31
32
  buildMessage(): chatV1.Schema$Message {
33
    return {cardsV2: [this.make()]};
34
  }
35
}
36